<?php
namespace Ygcl\Service;
use Think\Model;
class TermService extends Model{
	
	private $m;
	
	function __construct(){
		$this->m = D('YgclTerm');
	}
	
	
	public function _create_cache_Term(){
		$terminfo = $this->m->where(array('status' => 1))->order('id desc')->find();
		F('Termdata',$terminfo);
		
		$selectTerm = $this->m->order('id desc')->field('id,title')->select();
		F('selectTerm',$selectTerm);
		
	}
	
	public function _create_student_number_info(){
		$mm = M('YgclStudentNumber'); 
		$lessons = M('YgclLesson')->where(array('status'=>1))->select();
		$terminfo = $this->m->order('id desc')->field('id,title')->select();
		foreach ($terminfo as $tf){
			foreach ($lessons as $ls){
				$w = array('tid'=>$tf['id'],'lid'=>$ls['id']);
				if(!$mm->where($w)->find()){
					$d = $w;
					$d['create_time'] = Date('Y-m-d H:i:s');
					$d['update_time'] = Date('Y-m-d H:i:s');
					$mm->add($d);
				}
			}
		}
	}
	
   
}